package com.example.easy.Service.Impl;

import com.example.easy.Dto.Notice;
import com.example.easy.Dto.PublicSecurity;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Service.myservice.PublicSecurityServise;
import com.example.easy.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublicSecurityServiselmpl implements PublicSecurityServise {

    @Autowired
    PublicSecurityServise publicSecurityServise;


    @Override
    public int insPublicSecurity(PublicSecurity publicSecurity) {
        return publicSecurityServise.insPublicSecurity(publicSecurity);
    }

    @Override
    public int updatePublicSecurity(PublicSecurity publicSecurity) {
        if (publicSecurityServise.selectPublicSecurity(publicSecurity.getNumber()) != null) {
            publicSecurityServise.updatePublicSecurity(publicSecurity);
            return 1;
        } else return 0;
    }

    @Override
    public int deletePublicSecurity(int number) {
        if (publicSecurityServise.selectPublicSecurity(number)!=null) {
            publicSecurityServise.deletePublicSecurity(number);
            return 1;
        }else  return 0;
    }

    @Override
    public PublicSecurity selectPublicSecurity(int number) {
        if (publicSecurityServise.selectPublicSecurity(number)!=null) {
            return publicSecurityServise.selectPublicSecurity(number);
        }else
        return null;
    }

    @Override
    public List<PublicSecurity> selectall() {
        return publicSecurityServise.selectall();
    }
}
